package lrg10002.plugins.akperms;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;


public class LoggingRecord {
        
        private List<String> lines = new ArrayList<String>();
        private List<String> problems = new ArrayList<String>();
        private String title;
        
        public LoggingRecord(String s) {
                title = s;
        }
        
        public void addMessage(String s) {
               lines.add(s);
        }
        
        public void addProblem(String s) {
                problems.add(s);
        }
        
        public void printLog(Logger l) {
                if (problems.size() == 1) {
                        l.log(Level.WARNING, "[AKPermissions]  An error has occured during {0}:", title);
                        l.log(Level.WARNING, "/t{0}", problems.get(0));
                }else if (problems.size() > 1) {
                         l.log(Level.WARNING, "[AKPermissions]  Multiple errors have occured during {0}:", title);
                         for (String p : problems) {
                                 l.warning(p);
                         }
                         l.warning("[AKPermissions] End of error log. =========================");
                         l.log(Level.INFO, "[AKPermissions] Other messages during {0}:", title);
                         for (String m: lines) {
                                  l.log(Level.INFO, "/t{0}", m);
                         }
                         l.log(Level.INFO, "[AKPermissions] Finished log for {0}. =====", title);
                }else {
                        //no problems
                         l.log(Level.INFO, "[AKPermissions] {0} was successful.", title);
                         for (String m : lines) {
                                 l.log(Level.INFO, "/t{0}", m);
                         }
                         l.info("[AKPermissions] End of log. ==============");
                }
               
        }

}